package Code.QuestionNum_25_1_hxj;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class QuestionNum_25_1_hxj {
    public static void main(String[] args) throws Exception {
        List<Student> list = new ArrayList<>();

//        PrintWriter pw = new PrintWriter(new FileWriter("C:\\360Downloads\\1\\StudentInfo.txt"));
        PrintWriter pw = new PrintWriter(new FileOutputStream("C:\\360Downloads\\1\\StudentInfo.txt"));
        BufferedReader br = new BufferedReader(new FileReader("C:\\360Downloads\\1\\StudentInfo.txt"));

        Scanner sc = new Scanner(System.in);
        for (int i = 1; i <= 2; i++) {
            System.out.println("请输入第" + i + "个同学的姓名,性别,年龄:((录入格式:张三,男,25))");
            String s = sc.next();
            String[] split = s.split(",");
            Student stu = new Student(split[0], split[1], Integer.valueOf(split[2]));
            list.add(stu);
        }
        System.out.println(list);
        System.out.println("==================");
        for (Student student : list) {
            System.out.println(student);

        }
        for (Student student : list) {
            pw.println(student.getName() + "-" + student.getGender() + "-" + student.getAge());
        }
        pw.close();

        int len = 0;
        char[] ch = new char[1024];

        while ((len = br.read()) != -1) {
            System.out.print((char)len);
        }
        br.close();
    }
}
